/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package vnc;

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import org.netbeans.microedition.lcdui.SplashScreen;


/**
 * @author Administrator
 */
public class Interface extends MIDlet implements CommandListener {

    private boolean midletPaused = false;
//---- Object from canves to draw the desktop
    
    private String host;
    private String pass;
    private Display MyDisplay;
    
     VNC_Canves   vc;
     //<editor-fold defaultstate="collapsed" desc=" Generated Fields ">//GEN-BEGIN:|fields|0|
     private SplashScreen splashScreen;
     private Form ConnectionInput;
     private Spacer spacer2;
     private TextField passField;
     private TextField hostField;
     private Spacer spacer4;
     private ChoiceGroup choiceGroup;
     private Spacer spacer;
     private Form form;
     private List SavedData;
     private Form StartForm;
     private ImageItem imageItem;
     private TextField textField;
     private Command connect;
     private Command cancel;
     private Command backCommand1;
     private Command exitCommand;
     private Command okCommand1;
     private Command backCommand2;
     private Command okCommand2;
     private Command Select;
     private Command New;
     private Command Saved_Data;
     private Command backCommand;
     private Command NewConn;
     private Command New_conn;
     private Font font;
     private Image image1;
     private Font font1;
     //</editor-fold>//GEN-END:|fields|0|

    /**
     * The Interface constructor.
     */
//    public Interface() {
//        System.out.println("Iam here now");
//
//    }

     //<editor-fold defaultstate="collapsed" desc=" Generated Methods ">//GEN-BEGIN:|methods|0|
     //</editor-fold>//GEN-END:|methods|0|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: initialize ">//GEN-BEGIN:|0-initialize|0|0-preInitialize
     /**
      * Initilizes the application.
      * It is called only once when the MIDlet is started. The method is called before the <code>startMIDlet</code> method.
      */
     private void initialize() {//GEN-END:|0-initialize|0|0-preInitialize
        // write pre-initialize user code here
         exitCommand = new Command("Disconn", Command.EXIT, 0);//GEN-LINE:|0-initialize|1|0-postInitialize
        // write post-initialize user code here
     }//GEN-BEGIN:|0-initialize|2|
     //</editor-fold>//GEN-END:|0-initialize|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: startMIDlet ">//GEN-BEGIN:|3-startMIDlet|0|3-preAction
     /**
      * Performs an action assigned to the Mobile Device - MIDlet Started point.
      */
     public void startMIDlet() {//GEN-END:|3-startMIDlet|0|3-preAction
        // write pre-action user code here
         switchDisplayable(null, getSplashScreen());//GEN-LINE:|3-startMIDlet|1|3-postAction
    // write post-action user code here
     }//GEN-BEGIN:|3-startMIDlet|2|
     //</editor-fold>//GEN-END:|3-startMIDlet|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: resumeMIDlet ">//GEN-BEGIN:|4-resumeMIDlet|0|4-preAction
     /**
      * Performs an action assigned to the Mobile Device - MIDlet Resumed point.
      */
     public void resumeMIDlet() {//GEN-END:|4-resumeMIDlet|0|4-preAction
        // write pre-action user code here
//GEN-LINE:|4-resumeMIDlet|1|4-postAction
        // write post-action user code here
     }//GEN-BEGIN:|4-resumeMIDlet|2|
     //</editor-fold>//GEN-END:|4-resumeMIDlet|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: switchDisplayable ">//GEN-BEGIN:|5-switchDisplayable|0|5-preSwitch
     /**
      * Switches a current displayable in a display. The <code>display</code> instance is taken from <code>getDisplay</code> method. This method is used by all actions in the design for switching displayable.
      * @param alert the Alert which is temporarily set to the display; if <code>null</code>, then <code>nextDisplayable</code> is set immediately
      * @param nextDisplayable the Displayable to be set
      */
     public void switchDisplayable(Alert alert, Displayable nextDisplayable) {//GEN-END:|5-switchDisplayable|0|5-preSwitch
        // write pre-switch user code here
         Display display = getDisplay();//GEN-BEGIN:|5-switchDisplayable|1|5-postSwitch
         if (alert == null) {
             display.setCurrent(nextDisplayable);
         } else {
             display.setCurrent(alert, nextDisplayable);
         }//GEN-END:|5-switchDisplayable|1|5-postSwitch
    // write post-switch user code here
     }//GEN-BEGIN:|5-switchDisplayable|2|
     //</editor-fold>//GEN-END:|5-switchDisplayable|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: commandAction for Displayables ">//GEN-BEGIN:|7-commandAction|0|7-preCommandAction
     /**
      * Called by a system to indicated that a command has been invoked on a particular displayable.
      * @param command the Command that was invoked
      * @param displayable the Displayable where the command was invoked
      */
     public void commandAction(Command command, Displayable displayable) {//GEN-END:|7-commandAction|0|7-preCommandAction
        // write pre-action user code here
         if (displayable == ConnectionInput) {//GEN-BEGIN:|7-commandAction|1|24-preAction
             if (command == cancel) {//GEN-END:|7-commandAction|1|24-preAction
                // write pre-action user code here
                 exitMIDlet();//GEN-LINE:|7-commandAction|2|24-postAction
            // write post-action user code here
             } else if (command == connect) {//GEN-LINE:|7-commandAction|3|22-preAction
               if (choiceGroup.isSelected(0)) {

                    System.out.println("selected-------");
                    new Thread() {

                        public void run() {
                            new SaveConnData(hostField.getString(), passField.getString());
                        }
                    }.start();

                    System.out.println("selected-------");
                }
                switchDisplayable(null, getForm());
                System.out.println("connected");
                new Thread() {

                    public void run() {
                        host = hostField.getString();
                        pass = passField.getString();
                        // runapp(host,pass);
                        vc.init();
                        vc.setDisplay(getDisplay());
                        getDisplay().setCurrent(vc);

                        vc.Reconnect(host, pass);
                    }
                }.start();
                switchDisplayable(null, getForm());//GEN-LINE:|7-commandAction|4|22-postAction
            // write post-action user code here
               
             }//GEN-BEGIN:|7-commandAction|5|86-preAction
         } else if (displayable == SavedData) {
             if (command == List.SELECT_COMMAND) {//GEN-END:|7-commandAction|5|86-preAction
                 // write pre-action user code here
                 SavedDataAction();//GEN-LINE:|7-commandAction|6|86-postAction
                System.out.println("selected-------");
                new Thread() {

                    public void run() {
                        new SaveConnData("nnnnnnnn", "xxxxxxxx");
                    }
                }.start();

                System.out.println("selected-------");
                new Thread() {

                    public void run() {
                        ReadSavedData data = new ReadSavedData();
                        String DataString = data.getData();
                        int count = 0;
                        for (int i = 0; i < DataString.length(); i++) {
                            if (DataString.charAt(i) != '*') {
                                count++;
                            }

                        }
                        String[][] arr = new String[count / 2][2];
                        count=0;
                        for (int i = 0; i < DataString.length(); i++) {
                            if (DataString.charAt(i) != '*') {
                                if (DataString.charAt(i) != '|') {

                                    arr[i / 2][0] += DataString.charAt(i);

                                } else {
                                    arr[i / 2][1] += DataString.charAt(i);
                                }
                            } else {
                                SavedData.insert(count++, arr[i/2][0], null);
                            }
                        }

                    }
                }.start();
             } else if (command == New) {//GEN-LINE:|7-commandAction|7|91-preAction
                 // write pre-action user code here
                 switchDisplayable(null, getConnectionInput());//GEN-LINE:|7-commandAction|8|91-postAction
                 // write post-action user code here
             } else if (command == Select) {//GEN-LINE:|7-commandAction|9|89-preAction
                 host = SavedData.getString(SavedData.getSelectedIndex());
                 switchDisplayable(null, getConnectionInput());//GEN-LINE:|7-commandAction|10|89-postAction
                 hostField.setString(host);
             }//GEN-BEGIN:|7-commandAction|11|113-preAction
         } else if (displayable == StartForm) {
             if (command == New_conn) {//GEN-END:|7-commandAction|11|113-preAction
                 // write pre-action user code here
                 switchDisplayable(null, getConnectionInput());//GEN-LINE:|7-commandAction|12|113-postAction
                 // write post-action user code here
             } else if (command == Saved_Data) {//GEN-LINE:|7-commandAction|13|104-preAction
                 // write pre-action user code here
                 switchDisplayable(null, getSavedData());//GEN-LINE:|7-commandAction|14|104-postAction
                 // write post-action user code here
             } else if (command == backCommand) {//GEN-LINE:|7-commandAction|15|102-preAction
                 // write pre-action user code here
                 exitMIDlet();//GEN-LINE:|7-commandAction|16|102-postAction
                 // write post-action user code here
             }//GEN-BEGIN:|7-commandAction|17|31-preAction
         } else if (displayable == form) {
             if (command == exitCommand) {//GEN-END:|7-commandAction|17|31-preAction
          
                System.out.println("--------Diconnect now ");

                exitMIDlet();//GEN-LINE:|7-commandAction|18|31-postAction
            // write post-action user code here

             } else if (command == okCommand1) {//GEN-LINE:|7-commandAction|19|33-preAction
                // write pre-action user code here
             
//GEN-LINE:|7-commandAction|20|33-postAction
                // write post-action user code here
             }//GEN-BEGIN:|7-commandAction|21|16-preAction
         } else if (displayable == splashScreen) {
             if (command == SplashScreen.DISMISS_COMMAND) {//GEN-END:|7-commandAction|21|16-preAction
                // write pre-action user code here
                 switchDisplayable(null, getStartForm());//GEN-LINE:|7-commandAction|22|16-postAction
            // write post-action user code here
             }//GEN-BEGIN:|7-commandAction|23|7-postCommandAction
         }//GEN-END:|7-commandAction|23|7-postCommandAction
    // write post-action user code here
     }//GEN-BEGIN:|7-commandAction|24|
     //</editor-fold>//GEN-END:|7-commandAction|24|



     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: splashScreen ">//GEN-BEGIN:|14-getter|0|14-preInit
     /**
      * Returns an initiliazed instance of splashScreen component.
      * @return the initialized component instance
      */
     public SplashScreen getSplashScreen() {
         if (splashScreen == null) {//GEN-END:|14-getter|0|14-preInit
            // write pre-init user code here
             splashScreen = new SplashScreen(getDisplay());//GEN-BEGIN:|14-getter|1|14-postInit
             splashScreen.setTitle("VNC Viewer");
             splashScreen.setCommandListener(this);
             splashScreen.setFullScreenMode(true);
             splashScreen.setImage(getImage1());
             splashScreen.setText("Starting VNC viewer please wait");
             splashScreen.setTextFont(getFont());
             splashScreen.setTimeout(3000);//GEN-END:|14-getter|1|14-postInit
        // write post-init user code here
         }//GEN-BEGIN:|14-getter|2|
         return splashScreen;
     }
     //</editor-fold>//GEN-END:|14-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: ConnectionInput ">//GEN-BEGIN:|18-getter|0|18-preInit
     /**
      * Returns an initiliazed instance of ConnectionInput component.
      * @return the initialized component instance
      */
     public Form getConnectionInput() {
         if (ConnectionInput == null) {//GEN-END:|18-getter|0|18-preInit
            // write pre-init user code here
             ConnectionInput = new Form("VNC Input", new Item[] { getSpacer2(), getHostField(), getSpacer4(), getPassField(), getSpacer(), getChoiceGroup() });//GEN-BEGIN:|18-getter|1|18-postInit
             ConnectionInput.addCommand(getConnect());
             ConnectionInput.addCommand(getCancel());
             ConnectionInput.setCommandListener(this);//GEN-END:|18-getter|1|18-postInit
        // write post-init user code here
         }//GEN-BEGIN:|18-getter|2|
         return ConnectionInput;
     }
     //</editor-fold>//GEN-END:|18-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: form ">//GEN-BEGIN:|26-getter|0|26-preInit
     /**
      * Returns an initiliazed instance of form component.
      * @return the initialized component instance
      */
     public Form getForm() {
         if (form == null) {//GEN-END:|26-getter|0|26-preInit
            // write pre-init user code here
             form = new Form("VNC Display");//GEN-BEGIN:|26-getter|1|26-postInit
             form.addCommand(exitCommand);
             form.addCommand(getOkCommand1());
             form.setCommandListener(this);//GEN-END:|26-getter|1|26-postInit
        // write post-init user code here
         }//GEN-BEGIN:|26-getter|2|
         return form;
     }
     //</editor-fold>//GEN-END:|26-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: connect ">//GEN-BEGIN:|21-getter|0|21-preInit
     /**
      * Returns an initiliazed instance of connect component.
      * @return the initialized component instance
      */
     public Command getConnect() {
         if (connect == null) {//GEN-END:|21-getter|0|21-preInit
            // write pre-init user code here
             connect = new Command("Connect", Command.OK, 0);//GEN-LINE:|21-getter|1|21-postInit
        // write post-init user code here
         }//GEN-BEGIN:|21-getter|2|
         return connect;
     }
     //</editor-fold>//GEN-END:|21-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: cancel ">//GEN-BEGIN:|23-getter|0|23-preInit
     /**
      * Returns an initiliazed instance of cancel component.
      * @return the initialized component instance
      */
     public Command getCancel() {
         if (cancel == null) {//GEN-END:|23-getter|0|23-preInit
            // write pre-init user code here
             cancel = new Command("Exit", Command.BACK, 0);//GEN-LINE:|23-getter|1|23-postInit
        // write post-init user code here
         }//GEN-BEGIN:|23-getter|2|
         return cancel;
     }
     //</editor-fold>//GEN-END:|23-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand1 ">//GEN-BEGIN:|28-getter|0|28-preInit
     /**
      * Returns an initiliazed instance of backCommand1 component.
      * @return the initialized component instance
      */
     public Command getBackCommand1() {
         if (backCommand1 == null) {//GEN-END:|28-getter|0|28-preInit
            // write pre-init user code here
             backCommand1 = new Command("DisConn", Command.BACK, 0);//GEN-LINE:|28-getter|1|28-postInit
        // write post-init user code here
         }//GEN-BEGIN:|28-getter|2|
         return backCommand1;
     }
     //</editor-fold>//GEN-END:|28-getter|2|



     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand1 ">//GEN-BEGIN:|32-getter|0|32-preInit
     /**
      * Returns an initiliazed instance of okCommand1 component.
      * @return the initialized component instance
      */
     public Command getOkCommand1() {
         if (okCommand1 == null) {//GEN-END:|32-getter|0|32-preInit
            // write pre-init user code here
             okCommand1 = new Command("Option", Command.OK, 0);//GEN-LINE:|32-getter|1|32-postInit
        // write post-init user code here
         }//GEN-BEGIN:|32-getter|2|
         return okCommand1;
     }
     //</editor-fold>//GEN-END:|32-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer2 ">//GEN-BEGIN:|39-getter|0|39-preInit
     /**
      * Returns an initiliazed instance of spacer2 component.
      * @return the initialized component instance
      */
     public Spacer getSpacer2() {
         if (spacer2 == null) {//GEN-END:|39-getter|0|39-preInit
            // write pre-init user code here
             spacer2 = new Spacer(16, 1);//GEN-LINE:|39-getter|1|39-postInit
        // write post-init user code here
         }//GEN-BEGIN:|39-getter|2|
         return spacer2;
     }
     //</editor-fold>//GEN-END:|39-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: hostField ">//GEN-BEGIN:|41-getter|0|41-preInit
     /**
      * Returns an initiliazed instance of hostField component.
      * @return the initialized component instance
      */
     public TextField getHostField() {
         if (hostField == null) {//GEN-END:|41-getter|0|41-preInit
            // write pre-init user code here
             hostField = new TextField("Host:port", "host:port", 32, TextField.ANY);//GEN-LINE:|41-getter|1|41-postInit
        // write post-init user code here
         }//GEN-BEGIN:|41-getter|2|
         return hostField;
     }
     //</editor-fold>//GEN-END:|41-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: passField ">//GEN-BEGIN:|42-getter|0|42-preInit
     /**
      * Returns an initiliazed instance of passField component.
      * @return the initialized component instance
      */
     public TextField getPassField() {
         if (passField == null) {//GEN-END:|42-getter|0|42-preInit
            // write pre-init user code here
             passField = new TextField("Password", "", 32, TextField.ANY | TextField.PASSWORD);//GEN-LINE:|42-getter|1|42-postInit
        // write post-init user code here
         }//GEN-BEGIN:|42-getter|2|
         return passField;
     }
     //</editor-fold>//GEN-END:|42-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer4 ">//GEN-BEGIN:|44-getter|0|44-preInit
     /**
      * Returns an initiliazed instance of spacer4 component.
      * @return the initialized component instance
      */
     public Spacer getSpacer4() {
         if (spacer4 == null) {//GEN-END:|44-getter|0|44-preInit
            // write pre-init user code here
             spacer4 = new Spacer(16, 1);//GEN-LINE:|44-getter|1|44-postInit
        // write post-init user code here
         }//GEN-BEGIN:|44-getter|2|
         return spacer4;
     }
     //</editor-fold>//GEN-END:|44-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: choiceGroup ">//GEN-BEGIN:|45-getter|0|45-preInit
     /**
      * Returns an initiliazed instance of choiceGroup component.
      * @return the initialized component instance
      */
     public ChoiceGroup getChoiceGroup() {
         if (choiceGroup == null) {//GEN-END:|45-getter|0|45-preInit
            // write pre-init user code here
             choiceGroup = new ChoiceGroup("Save my password:", Choice.MULTIPLE);//GEN-BEGIN:|45-getter|1|45-postInit
             choiceGroup.append("Yes ", null);
             choiceGroup.setSelectedFlags(new boolean[] { false });
             choiceGroup.setFont(0, null);//GEN-END:|45-getter|1|45-postInit
        // write post-init user code here
         }//GEN-BEGIN:|45-getter|2|
         return choiceGroup;
     }
     //</editor-fold>//GEN-END:|45-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: spacer ">//GEN-BEGIN:|69-getter|0|69-preInit
     /**
      * Returns an initiliazed instance of spacer component.
      * @return the initialized component instance
      */
     public Spacer getSpacer() {
         if (spacer == null) {//GEN-END:|69-getter|0|69-preInit
            // write pre-init user code here
             spacer = new Spacer(30, 20);//GEN-LINE:|69-getter|1|69-postInit
        // write post-init user code here
         }//GEN-BEGIN:|69-getter|2|
         return spacer;
     }
     //</editor-fold>//GEN-END:|69-getter|2|








     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand2 ">//GEN-BEGIN:|73-getter|0|73-preInit
     /**
      * Returns an initiliazed instance of backCommand2 component.
      * @return the initialized component instance
      */
     public Command getBackCommand2() {
         if (backCommand2 == null) {//GEN-END:|73-getter|0|73-preInit
            // write pre-init user code here
             backCommand2 = new Command("Back", Command.BACK, 0);//GEN-LINE:|73-getter|1|73-postInit
        // write post-init user code here
         }//GEN-BEGIN:|73-getter|2|
         return backCommand2;
     }
     //</editor-fold>//GEN-END:|73-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: okCommand2 ">//GEN-BEGIN:|75-getter|0|75-preInit
     /**
      * Returns an initiliazed instance of okCommand2 component.
      * @return the initialized component instance
      */
     public Command getOkCommand2() {
         if (okCommand2 == null) {//GEN-END:|75-getter|0|75-preInit
            // write pre-init user code here
             okCommand2 = new Command("Ok", Command.OK, 0);//GEN-LINE:|75-getter|1|75-postInit
        // write post-init user code here
         }//GEN-BEGIN:|75-getter|2|
         return okCommand2;
     }
     //</editor-fold>//GEN-END:|75-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: font ">//GEN-BEGIN:|81-getter|0|81-preInit
     /**
      * Returns an initiliazed instance of font component.
      * @return the initialized component instance
      */
     public Font getFont() {
         if (font == null) {//GEN-END:|81-getter|0|81-preInit
            // write pre-init user code here
             font = Font.getFont(Font.FACE_SYSTEM, Font.STYLE_ITALIC, Font.SIZE_MEDIUM);//GEN-LINE:|81-getter|1|81-postInit
            // write post-init user code here
         }//GEN-BEGIN:|81-getter|2|
         return font;
     }
     //</editor-fold>//GEN-END:|81-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: image1 ">//GEN-BEGIN:|83-getter|0|83-preInit
     /**
      * Returns an initiliazed instance of image1 component.
      * @return the initialized component instance
      */
     public Image getImage1() {
         if (image1 == null) {//GEN-END:|83-getter|0|83-preInit
             // write pre-init user code here
             try {//GEN-BEGIN:|83-getter|1|83-@java.io.IOException
                 image1 = Image.createImage("/Image/icon-java.png");
             } catch (java.io.IOException e) {//GEN-END:|83-getter|1|83-@java.io.IOException
                 e.printStackTrace();
             }//GEN-LINE:|83-getter|2|83-postInit
             // write post-init user code here
         }//GEN-BEGIN:|83-getter|3|
         return image1;
     }
     //</editor-fold>//GEN-END:|83-getter|3|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: SavedData ">//GEN-BEGIN:|84-getter|0|84-preInit
     /**
      * Returns an initiliazed instance of SavedData component.
      * @return the initialized component instance
      */
     public List getSavedData() {
         if (SavedData == null) {//GEN-END:|84-getter|0|84-preInit
             // write pre-init user code here
             SavedData = new List("Saved Data", Choice.IMPLICIT);//GEN-BEGIN:|84-getter|1|84-postInit
             SavedData.append("192.168.1.5:5900", null);
             SavedData.addCommand(getSelect());
             SavedData.addCommand(getNew());
             SavedData.setCommandListener(this);
             SavedData.setSelectedFlags(new boolean[] { true });//GEN-END:|84-getter|1|84-postInit
             // write post-init user code here
         }//GEN-BEGIN:|84-getter|2|
         return SavedData;
     }
     //</editor-fold>//GEN-END:|84-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Method: SavedDataAction ">//GEN-BEGIN:|84-action|0|84-preAction
     /**
      * Performs an action assigned to the selected list element in the SavedData component.
      */
     public void SavedDataAction() {//GEN-END:|84-action|0|84-preAction
         // enter pre-action user code here
         String __selectedString = getSavedData().getString(getSavedData().getSelectedIndex());//GEN-BEGIN:|84-action|1|92-preAction
         if (__selectedString != null) {
             if (__selectedString.equals("192.168.1.5:5900")) {//GEN-END:|84-action|1|92-preAction
                 // write pre-action user code here
//GEN-LINE:|84-action|2|92-postAction
                 // write post-action user code here
             }//GEN-BEGIN:|84-action|3|84-postAction
         }//GEN-END:|84-action|3|84-postAction
         // enter post-action user code here
     }//GEN-BEGIN:|84-action|4|
     //</editor-fold>//GEN-END:|84-action|4|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Select ">//GEN-BEGIN:|88-getter|0|88-preInit
     /**
      * Returns an initiliazed instance of Select component.
      * @return the initialized component instance
      */
     public Command getSelect() {
         if (Select == null) {//GEN-END:|88-getter|0|88-preInit
             // write pre-init user code here
             Select = new Command("Ok", Command.OK, 0);//GEN-LINE:|88-getter|1|88-postInit
             // write post-init user code here
         }//GEN-BEGIN:|88-getter|2|
         return Select;
     }
     //</editor-fold>//GEN-END:|88-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: New ">//GEN-BEGIN:|90-getter|0|90-preInit
     /**
      * Returns an initiliazed instance of New component.
      * @return the initialized component instance
      */
     public Command getNew() {
         if (New == null) {//GEN-END:|90-getter|0|90-preInit
             // write pre-init user code here
             New = new Command("Cancel", Command.CANCEL, 0);//GEN-LINE:|90-getter|1|90-postInit
             // write post-init user code here
         }//GEN-BEGIN:|90-getter|2|
         return New;
     }
     //</editor-fold>//GEN-END:|90-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: StartForm ">//GEN-BEGIN:|95-getter|0|95-preInit
     /**
      * Returns an initiliazed instance of StartForm component.
      * @return the initialized component instance
      */
     public Form getStartForm() {
         if (StartForm == null) {//GEN-END:|95-getter|0|95-preInit
             // write pre-init user code here
             StartForm = new Form("form1", new Item[] { getImageItem(), getTextField() });//GEN-BEGIN:|95-getter|1|95-postInit
             StartForm.addCommand(getBackCommand());
             StartForm.addCommand(getSaved_Data());
             StartForm.addCommand(getNew_conn());
             StartForm.setCommandListener(this);//GEN-END:|95-getter|1|95-postInit
             // write post-init user code here
         }//GEN-BEGIN:|95-getter|2|
         return StartForm;
     }
     //</editor-fold>//GEN-END:|95-getter|2|





     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: backCommand ">//GEN-BEGIN:|101-getter|0|101-preInit
     /**
      * Returns an initiliazed instance of backCommand component.
      * @return the initialized component instance
      */
     public Command getBackCommand() {
         if (backCommand == null) {//GEN-END:|101-getter|0|101-preInit
             // write pre-init user code here
             backCommand = new Command("Back", Command.BACK, 0);//GEN-LINE:|101-getter|1|101-postInit
             // write post-init user code here
         }//GEN-BEGIN:|101-getter|2|
         return backCommand;
     }
     //</editor-fold>//GEN-END:|101-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: Saved_Data ">//GEN-BEGIN:|103-getter|0|103-preInit
     /**
      * Returns an initiliazed instance of Saved_Data component.
      * @return the initialized component instance
      */
     public Command getSaved_Data() {
         if (Saved_Data == null) {//GEN-END:|103-getter|0|103-preInit
             // write pre-init user code here
             Saved_Data = new Command("Saved Data", Command.OK, 0);//GEN-LINE:|103-getter|1|103-postInit
             // write post-init user code here
         }//GEN-BEGIN:|103-getter|2|
         return Saved_Data;
     }
     //</editor-fold>//GEN-END:|103-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: NewConn ">//GEN-BEGIN:|107-getter|0|107-preInit
     /**
      * Returns an initiliazed instance of NewConn component.
      * @return the initialized component instance
      */
     public Command getNewConn() {
         if (NewConn == null) {//GEN-END:|107-getter|0|107-preInit
             // write pre-init user code here
             NewConn = new Command("Screen", Command.SCREEN, 0);//GEN-LINE:|107-getter|1|107-postInit
             // write post-init user code here
         }//GEN-BEGIN:|107-getter|2|
         return NewConn;
     }
     //</editor-fold>//GEN-END:|107-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: font1 ">//GEN-BEGIN:|111-getter|0|111-preInit
     /**
      * Returns an initiliazed instance of font1 component.
      * @return the initialized component instance
      */
     public Font getFont1() {
         if (font1 == null) {//GEN-END:|111-getter|0|111-preInit
             // write pre-init user code here
             font1 = Font.getDefaultFont();//GEN-LINE:|111-getter|1|111-postInit
             // write post-init user code here
         }//GEN-BEGIN:|111-getter|2|
         return font1;
     }
     //</editor-fold>//GEN-END:|111-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: New_conn ">//GEN-BEGIN:|112-getter|0|112-preInit
     /**
      * Returns an initiliazed instance of New_conn component.
      * @return the initialized component instance
      */
     public Command getNew_conn() {
         if (New_conn == null) {//GEN-END:|112-getter|0|112-preInit
             // write pre-init user code here
             New_conn = new Command("New user", Command.OK, 0);//GEN-LINE:|112-getter|1|112-postInit
             // write post-init user code here
         }//GEN-BEGIN:|112-getter|2|
         return New_conn;
     }
     //</editor-fold>//GEN-END:|112-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: imageItem ">//GEN-BEGIN:|115-getter|0|115-preInit
     /**
      * Returns an initiliazed instance of imageItem component.
      * @return the initialized component instance
      */
     public ImageItem getImageItem() {
         if (imageItem == null) {//GEN-END:|115-getter|0|115-preInit
             // write pre-init user code here
             imageItem = new ImageItem("Mobile VNC", getImage1(), ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | ImageItem.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2, "VNC", Item.PLAIN);//GEN-LINE:|115-getter|1|115-postInit
             // write post-init user code here
         }//GEN-BEGIN:|115-getter|2|
         return imageItem;
     }
     //</editor-fold>//GEN-END:|115-getter|2|

     //<editor-fold defaultstate="collapsed" desc=" Generated Getter: textField ">//GEN-BEGIN:|116-getter|0|116-preInit
     /**
      * Returns an initiliazed instance of textField component.
      * @return the initialized component instance
      */
     public TextField getTextField() {
         if (textField == null) {//GEN-END:|116-getter|0|116-preInit
             // write pre-init user code here
             textField = new TextField("Welcome", "Choose from menu :\n\n1- saved data to use pre-entered\n    data.\n\n2- new connection to enter new data.", 100, TextField.ANY);//GEN-BEGIN:|116-getter|1|116-postInit
             textField.setLayout(ImageItem.LAYOUT_CENTER | Item.LAYOUT_TOP | Item.LAYOUT_BOTTOM | Item.LAYOUT_VCENTER | ImageItem.LAYOUT_NEWLINE_AFTER | Item.LAYOUT_2);//GEN-END:|116-getter|1|116-postInit
             // write post-init user code here
         }//GEN-BEGIN:|116-getter|2|
         return textField;
     }
     //</editor-fold>//GEN-END:|116-getter|2|





    /**
     * Returns a display instance.
     * @return the display instance.
     */
    public Display getDisplay() {
        return Display.getDisplay(this);
    }

    /**
     * Exits MIDlet.
     */
    public   void exitMIDlet() {
       switchDisplayable(null, null);
        destroyApp(true);
        notifyDestroyed();
    }

    /**
     * Called when MIDlet is started.
     * Checks whether the MIDlet have been already started and initialize/starts or resumes the MIDlet.
     */
    public void startApp() {
        if (midletPaused) {
            resumeMIDlet();
        } else {
            initialize();
            startMIDlet();
           vc = new VNC_Canves(this);
        }
        midletPaused = false;
    }

    /**
     * Called when MIDlet is paused.
     */
    public void pauseApp() {
        midletPaused = true;
    }

    /**
     * Called to signal the MIDlet to terminate.
     * @param unconditional if true, then the MIDlet has to be unconditionally terminated and all resources has to be released.
     */
    public void destroyApp(boolean unconditional) {
    }
   

}
